﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace FourPartHarmony3 {
    class VirtualScoreElement : IVirtualChild {
        private ScoreElementPathes.Item mPathItem;
        private Vector mPosition;
        private Rect mBoundary;
        private Path mPathDisplay;

        static private Size TypicalSize = new Size(100, 100);

        public VirtualScoreElement(ScoreElementPathes.Item pathItem, Vector pos) {
            mPathItem = pathItem;
            mPosition = new Vector(pos.X, pos.Y);

            var b = pathItem.boundary;
            mBoundary = new Rect(b.Left+pos.X, b.Top+pos.Y, b.Width, b.Height);
        }

        public System.Windows.Rect Bounds {
            get { return mBoundary; }
        }

        public System.Windows.UIElement Visual {
            get {
                return mPathDisplay;
            }
        }

        public bool Focusable { get; set; }

        public System.Windows.UIElement CreateVisual(HorizontalVirtualCanvas parent) {
            var p = new Path();
            p.Fill = mPathItem.path.Fill;
            p.Data = mPathItem.path.Data;
            p.Stroke = mPathItem.path.Stroke;
            p.StrokeThickness = mPathItem.path.StrokeThickness;

            mPathDisplay = p;
            return mPathDisplay;
        }

        public void DisposeVisual() {
            mPathDisplay = null;
        }
    }
}
